package com.bieyang.anjia.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;

public class ApplicationUtils {
	public static boolean  netOK=true;
	public String address, port, username, password, imsi;
	 public String xml;
	 public int ret=-1;
	
	//监测网络
	public static boolean netState(Context context){
		// 获得网络连接服务
				ConnectivityManager connManager = (ConnectivityManager) context
						.getSystemService(Context.CONNECTIVITY_SERVICE);
				// State state = connManager.getActiveNetworkInfo().getState();
				// 获取WIFI网络连接状态
				State stateWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
						.getState();
				// 获取GPRS网络连接状态
				State stateGprs = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
						.getState();
				// 判断是否正在使用WIFI网络
				if ((State.CONNECTED == stateWifi) || (State.CONNECTED==stateGprs)) {
					netOK = true;
				}else{
					netOK = false;
				}
				
				return netOK;
	} 
	 
}
